package org.jiuling.tencentcloud.cos.spring.config;

import org.jiuling.tencentcloud.cos.TencentCloudCos;
import org.jiuling.tencentcloud.cos.client.builder.CosClientBuilder;
import org.jiuling.tencentcloud.cos.client.builder.CosStsClientBuilder;
import org.jiuling.tencentcloud.cos.client.factory.CosClientFactory;
import org.jiuling.tencentcloud.cos.config.TencentCosConfig;
import org.jiuling.tencentcloud.cos.config.TencentCosStsConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 腾讯云CosSpringBean配置
 * @author 紫灵
 * @date 2024年02月23日 21时55分55秒
 */
@Configuration
public class TencentCloudCosSpringBeanConfig {

    @Bean
    @ConfigurationProperties(prefix = "jiu-ling.tencent.cos")
    public TencentCosConfig tencentCosConfig(){
        return new TencentCosConfig();
    }

    @Bean
    @ConfigurationProperties(prefix = "jiu-ling.tencent.cos.sts")
    public TencentCosStsConfig tencentCosStsConfig(){
        return new TencentCosStsConfig();
    }

    @Bean
    public CosClientFactory cosStsClient(){
        return new CosStsClientBuilder(tencentCosConfig(),tencentCosStsConfig());
    }

    @Bean
    public CosClientFactory cosClient(){
        return new CosClientBuilder(tencentCosConfig());
    }

    @Bean
    public TencentCloudCos tencentCloudCos(){
        return new TencentCloudCos(tencentCosConfig(),cosStsClient());
    }


}

